﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SD.Commons.DataFilters;
using SD.DataAccess;
namespace SD.Business
{
    /// <summary>
    /// Business Class for Department
    /// </summary>
    class DepartmentBUS
    {
        /// <summary>
        /// Department dao for connecting to database
        /// </summary>
        private static readonly DepartmentDao Dao = new DepartmentDao();

        /// <summary>
        /// The method for getting department records.
        /// </summary>
        /// <param name="filter">filter</param>
        /// <param name="sortType">sortType</param>
        /// <param name="startRowIndex">startRowIndex</param>
        /// <param name="maximumRows">maximumRows</param>
        /// <returns>Departments</returns>
        public IQueryable<Department> ListDepartment(DepartmentFilter filter,string sortType,int startRowIndex,int maximumRows=15)
        {
            return Dao.GetList(filter, sortType, startRowIndex, maximumRows);
        }

        /// <summary>
        /// The method for getting number of query list
        /// </summary>
        /// <param name="filter">filter</param>
        /// <returns>Departments</returns>
        public int GetListCount(DepartmentFilter filter)
        {
            return Dao.GetListCount(filter);
        }

        /// <summary>
        /// The method for mark in-active a record by departmentId
        /// </summary>
        /// <param name="departmentId"></param>
        /// <returns>true if success.</returns>
        public bool MarkInActive(int departmentId)
        {
            return Dao.MarkInActive(departmentId);
        }

        //---------------------------------------VIDT------------------------------------------
        /// <summary>
        /// Gets the department by id.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        public static Department GetDepartmentById(int id)
        {
            return Dao.GetDepartmentId(id);
        }

        /// <summary>
        /// Inserts the department.
        /// </summary>
        /// <param name="department">The department.</param>
        /// <returns></returns>
        public static bool InsertDepartment(Department department)
        {
            return Dao.AddDepartment(department);
        }

        /// <summary>
        /// Edits the department.
        /// </summary>
        /// <param name="department">The department.</param>
        /// <returns></returns>
        public static bool EditDepartment(Department department)
        {
            return Dao.EditDepartment(department);
        }

        /// <summary>
        /// Adds the department.
        /// </summary>
        /// <param name="newDepartment">The new department.</param>
        /// <returns></returns>
        public static bool AddDepartment(Department newDepartment)
        {
            return Dao.AddDepartment(newDepartment);
        }

        /// <summary>
        /// Checks the name of the department.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        public static bool CheckDepartmentName(string name)
        {
            return Dao.CheckDepartmentName(name);
        }

        /// <summary>
        /// Sets the department status.
        /// </summary>
        /// <param name="departmentId">The department id.</param>
        /// <param name="status">if set to <c>true</c> [status].</param>
        /// <returns></returns>
        public static bool SetDepartmentStatus(int departmentId, bool status)
        {
            return Dao.SetDepartmentStatus(departmentId, status);
        }
    }
}
